<!--  / warpper  -->
<main class="warpper">

    <div class="joinContent">
        <ul class="joinNav">
            <li class="on">招贤纳士</li>
            <li>商务合作</li>
        </ul>
        <div class="joinRight">
            <!-- 招贤纳士 -->
            <div class="joinSec1">
                <ul class="joinSec1_list">
                    {foreach $join as $row}
                    <li>
                        <div class="joinSec1_name">{$row.name}</div>
                        <div class="joinSec1_txt">
                            {$row.content}
                        </div>
                    </li>
                    {/foreach}
                </ul>
                <div class="publicMore joinSec1_send">
                    <a href="javascript:;">Send resume <input type="file"></a>
                </div>
            </div>
            <!-- 商务合作 -->
            <div class="joinSec2">
                <h6>商务合作</h6>
                <div class="joinSec2_con">
                    <form id="message" class="joinSec2_form" action="">
                        <div class="joinSec2_input">
                            <input type="text" name="name" placeholder="姓名">
                        </div>
                        <div class="joinSec2_input">
                            <input type="text" name="mobile" placeholder="电话">
                        </div>
                        <div class="joinSec2_input">
                            <input type="text" name="email" placeholder="邮箱">
                        </div>
                        <div class="joinSec2_input">
                            <input type="text" name="content" placeholder="内容">
                        </div>
                        <div class="publicMore joinSec2_send">
                            <a href="javascript:;" onclick="sendMessage()">Send</a>
                        </div>
                    </form>
                    <div class="joinSec2_phone">
                        <img src="__CDN__/static/images/logo6.png" alt="" width="100%">
                        <div class="joinSec2_phoneCon">
                            <img src="__CDN__/static/images/down.png" alt="">
                            <h6>如果您想与我们合作，请留下您的联系方式.</h6>
                            <p>4008810573</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</main>
<!--  / warpper  -->

<script>

    function sendMessage() {
        var name = $("input[name='name']").val();
        var mobile = $("input[name='mobile']").val();
        var email = $("input[name='email']").val();
        var content = $("input[name='content']").val();
        $.ajax({
            url: '/api/index/sendBusiness',
            type: 'POST',
            beforeSend: function(xhr) {
                xhr.setRequestHeader("token", "{$token}");
            },
            data: {
                name,
                mobile,
                email,
                content
            },
            success: function(res) {
                alert(res.msg);
            },
            error: function() {
                alert('提交失败');
            }
        })
    }

    $(function () {
        $('input[type="file"]').on('change', function() {
            var file = $(this)[0].files[0];
            console.log(file.name + ' has been selected');
            //执行上传文件的代码
            var formData = new FormData();
            formData.append('file', file);

            $.ajax({
                url: '/api/common/upload',
                type: 'POST',
                beforeSend: function(xhr) {
                    xhr.setRequestHeader("token", "{$token}");
                },
                data: formData,
                cache: false,
                contentType: false,
                processData: false,
                success: function(res) {
                    if(res.code == 1){
                        $.ajax({
                            url: '/api/index/sendResume',
                            type: 'POST',
                            beforeSend: function(xhr) {
                                xhr.setRequestHeader("token", "{$token}");
                            },
                            data: {
                                file: res.data.url
                            },
                            success: function(res) {
                                alert(res.msg);
                            }
                        })
                    }else{
                        alert(res.msg)
                    }
                },
                error: function() {
                    console.log('上传失败');
                }
            });
        });

        // 左侧导航点击
        $('body').on('click', '.joinNav li', function () {
            $(this).addClass('on').siblings('li').removeClass('on');
            $('.joinRight>div').eq($(this).index()).show().siblings().hide();
        })
        // 岗位展开
        $('body').on('click', '.joinSec1_name', function () {
            if ($(this).parent('li').hasClass('on')) {
                $(this).parent('li').removeClass('on');
                $(this).siblings('.joinSec1_txt').slideUp();
            } else {
                $(this).parent('li').addClass('on');
                $(this).siblings('.joinSec1_txt').slideDown();
            }
        })

    })

    $(window).ready(function () {
        $('.headerNav:last-child li').eq(1).addClass('on');
    })
    $(window).load(function () {
        if ($(window).width() <= 768) {
            $('.joinContent').addClass('on');
        }
    })
    $(window).resize(function () {

    })

    $(window).scroll(function () {
        var h = $(window).scrollTop()


    })

</script>